% demonstrate the use of dXdots with arbitrary distributions of dot motion
%   this is a new dXdots feature added by BSH on 30 April 2008
%
%   Show 4 fields of dots:
%   red     - two directions at once,   100% coherence
%   yellow  - gaussian directions,      100% coherence
%   blue    - two directions at once,   51.2% coherence
%   green   - gaussian directions,      51.2% coherence

rInit('local')

% pick two discrete directions to show
%   pick relative weights for these directions
%   convert weights to CDF
twoDomain = [80 150];
twoPmf = [45 50];
twoCDF = cumsum(twoPmf)/sum(twoPmf);

% pick a domain for the gaussian (full circle)
% get a CDF for the gaussian (medium spread)
gaussDomain = 0:2:179;
gaussDomain = twoDomain;
gaussCDF = normcdf(gaussDomain, 90, 15);

rAdd('dXtarget', 5, ...
    'diameter',     .2, ...
    'color',        [64 64 64 64], ...
    'x',            {-8 8 -8 8, 0}, ...
    'y',            {6 6 -6 -6. 0});

rAdd('dXdots',      4, ...
    'diameter',     7, ...
    'size',         3, ...
    'density',      50, ...
    'speed',        4, ...
    'groupMotion',  false, ...
    'x',            {-8 8 -8 8}, ...
    'y',            {6 6 -6 -6}, ...
    'coherence',    {100 100 51.2 51.2}, ...
    'color',        {[255 0 0], [255 255 0], [0 0 255], [0 128 0]}, ...
    'dirDomain',    {twoDomain, gaussDomain, twoDomain, gaussDomain}, ...
    'dirCDF',       {twoCDF, gaussCDF, twoCDF, gaussCDF});

rGraphicsShow;
rGraphicsDraw(inf);

rDone